#!/bin/sh

##############################################################################
#  OpenDomo: Security & Domotics
#  Copyright (C) 2009  Isidro Catalan <skarvin@gmail.com>
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
##############################################################################

VERSION=`date '+%Y%m%d'`
ARCH=i486
PKG="odvision"
USR="--owner 1000 --group 100 --same-permissions"
EXCLUDE=' --exclude "*~" --exclude .svn ' 


rm -f pkg/*.tar.gz

chmod 0700 -R ./usr/local/opendomo/services/config/*
chmod 0750 ./usr/local/opendomo/services/control/*
chmod 0750 ./usr/local/opendomo/odvideo-utils/*

echo '
TARGET_DIR="/media/opendomodistro/captures"
' > etc/opendomo/video/common.conf.orig 

# TODO: remove this line from css when advanced odvision
if ! grep cameraShow_basic var/www/css/cameraShow.sh.css 2> /dev/null > /dev/null; then
   cp var/www/css/cameraShow.sh.css /tmp/cameraShow.sh.css_old
   echo '@import url("cameraShow_basic.sh.css");' > var/www/css/cameraShow.sh.css
   cat /tmp/cameraShow.sh.css_old >> var/www/css/cameraShow.sh.css
   rm /tmp/cameraShow.sh.css_old
fi

echo "OpenDomo Vision" > pkg/$PKG.desc
echo "Control multiple IP cameras in your network from a single interface" >> pkg/$PKG.desc
cp pkg/*.desc ./var/pkg
rm -fr ./usr/local/opendomo/*~
tar zcf  pkg/$PKG-$VERSION.od.$ARCH.tar.gz etc/init.d/odvision_camaccess etc/opendomo usr/local/opendomo/services/control/cameraShow.sh usr/local/opendomo/services/config/video/manageCameras.sh usr/local/opendomo/services/syscript/getStreamingURL.sh usr/local/opendomo/services/syscript/*IPCam.sh usr/local/opendomo/services/syscript/eh_conversor.sh usr/local/opendomo/services/control/cameraShow.sh usr/local/opendomo/odvideo-utils usr/share var/opendomo var/pkg var/www $USR $EXCLUDE
echo "Archivo creado"
